home *** CD-ROM | disk | FTP | other *** search
- # subject-level access: show all the messages associated
- # with a particular subject.
- # and display one
- # Copyright (C) 1994 Afzal Ballim
-
- ############################################################
- #
- # WFCommandSubject: display all the messages of a subject
- #
- sub WFCommandSubject {
- local ($direction,%in)=@_;
- local ($message,$forum,$subject,$thelist,@messages,
- $forumdec,$subjectdec,$thedir,@tmp,$mform,
- @ms,%mb);
-
- # 4 possibilities
- # 1) called first from the FORUM level, so must create
- # the list of articles, etc.
- # 2) called by "pick message" - list of articles exists,
- # so get appropriate one
- # 3a) called by "previous" ...
- # 3b) called by "next" ... similar to 2
-
- # non-dependent things: must know forum and subject
- if ($in{"forum"} eq "") {
- return "No Forum was selected.";
- }
- local ($forum) = $in{"forum"};
- local ($forumdec)=&WFDecodeDatum($forum);
- if ($in{"subject"} eq "") {
- return "No subject was selected.";
- }
- local ($subject) = $in{"subject"};
- local ($subjectdec)=&WFDecodeDatum($subject);
-
- # we do this each time through instead of saving the info
- # to allow for re-scanning on each pass, i.e., in case things have changed
- $thedir="ABSWFSPOOL/$forum/$subject";
- opendir(DIR,$thedir)||return "$subjectdec: No such subject could be found!";
- @tmp=readdir(DIR);
- close(DIR);
- for (@tmp) {
- next if $_ eq '.';
- next if $_ eq '..';
- push(@messages,$_);
- }
- if ($in{"sortmethod"} eq "") {
- $in{"sortmethod"}="alphabetic";
- }
- if ($in{"sortmethod"} eq "alphabetic") {
- @messages=sort @messages; }
- elsif ($in{"sortmethod"} eq "mostrecent") {
- @messages=sort WFSubjectstatbymostrecent @messages;
- }
-
- $thelist="";
- foreach $message (@messages) {
- $mform=join(' <= ',split(';',$message));
- $thelist = $thelist . <<EI
- <li>
- <form method="POST" action="STD_DOCOMMAND">
- <input type="hidden" name="command" value="message">
- <input type="hidden" name="forum" value="$forum">
- <input type="hidden" name="subject" value="$subject">
- <input type="hidden" name="message" value="$message">
- <input type="hidden" name="sortmethod" value="$in{sortmethod}">
- <input type="submit" value="$mform">
- </form>
- </li>
- EI
- }
-
- # which of the 4 is it?
- if ($direction eq "this") {
- $message=$in{"message"};
- if ($message eq "None" || $message eq "none" || $message eq "") {
- return "No message found!\n";}
- } elsif ($direction eq "next") {
- if ($#messages < 1) {return "No other messages.\n";}
- @ms=@messages;
- while (@ms && @ms[0] ne $in{"message"}) {shift @ms;};
- if ($#ms < 1) {return "No next message.\n";}
- $message=@ms[1];
- } elsif ($direction eq "prev") {
- if ($#messages < 1) {return "No other messages.\n";}
- @ms=reverse @messages;
- while (@ms && @ms[0] ne $in{"message"}) {shift @ms;};
- if ($#ms < 1) {return "No previous message.\n";}
- $message=@ms[1];
- } else {
- $message=@messages[0];
- }
-
- %mb=&WFGetFile("ABSWFSPOOL/$forum/$subject/$message");
- if (%mb == 0) {return "No such message!\n";}
- if ($mb{"xref"} eq "") {$mb{"xref"}="none"};
- if ($mb{"expiry"} eq "") {$mb{"expiry"}="7 days"};
-
- if ($thelist eq "") {$thelist="<h2>No messages on $subjectdec.</p></h2>";}
- $mform=join(' <= ',split(';',$message));
- $thelist =~ s^value="$mform"^value="$mform (current)"^g;
-
- if ($in{sortmethod} eq "alphabetic") {
- !&WFIncFile("ABSWFHTML/SUBJECT.HTML",
- ENCFORUM,"$forum",
- THEFORUM,"$forumdec",
- ENCSUBJECT,"$subject",
- THESUBJECT,"$subjectdec",
- THEMESSAGE,"$message",
- THEPOSTER,"$mb{poster}",
- THEPEMAIL,"$mb{email}",
- THEPHURL,"$mb{hurl}",
- THEPDT,"$mb{date}",
- THEPXREF,"$mb{xref}",
- THEXPIRE,"$mb{expiry}",
- THEMBODY,"$mb{body}",
- MESSAGELIST,"$thelist",
- SORTYPE,"$in{sortmethod}",
- ASORT,checked,
- MRCSORT,'')
- } else {
- &WFIncFile("ABSWFHTML/SUBJECT.HTML",
- ENCFORUM,"$forum",
- THEFORUM,"$forumdec",
- ENCSUBJECT,"$subject",
- THESUBJECT,"$subjectdec",
- THEMESSAGE,"$message",
- THEPOSTER,"$mb{poster}",
- THEPEMAIL,"$mb{email}",
- THEPHURL,"$mb{hurl}",
- THEPDT,"$mb{date}",
- THEPXREF,"$mb{xref}",
- THEXPIRE,"$mb{expiry}",
- THEMBODY,"$mb{body}",
- MESSAGELIST,"$thelist",
- SORTYPE,"$in{sortmethod}",
- ASORT,'',
- MRCSORT,checked)
- }
- return "";
- }
-
- sub WFSubjectstatbymostrecent {
- local (@d1) = stat("ABSWFSPOOL/$forum/$subject/$a");
- local (@d2) = stat("ABSWFSPOOL/$forum/$subject/$b");
- $d2[9] <=> $d1[9];
- }
- 1;
-